/**
 * This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
 */
package com.softwarecraftsmen.functors;

import org.jetbrains.annotations.NotNull;

public abstract class UnaryReturningFunctor<A, R>
{
	@NotNull
	public abstract R closure(@NotNull final A a);

	@NotNull
	public final UnaryReturningFunctor<A, R> curry()
	{
		return this;
	}

	@NotNull
	public final NullaryReturningFunctor curry(final @NotNull A a)
	{
		return new NullaryReturningFunctor()
		{
			@NotNull
			public R closure()
			{
				return UnaryReturningFunctor.this.closure(a);
			}
		};
	}

	@NotNull
	public static <A> UnaryReturningFunctor<A, Boolean> not(final @NotNull UnaryReturningFunctor<A, Boolean> selector)
	{
		return new UnaryReturningFunctor<A, Boolean>()
		{
			@NotNull
			public Boolean closure(@NotNull final A a)
			{
				return selector.closure(a).not();
			}
		};
	}
}
